<?php

class PracticeTestModel extends CoreModel {

	function __construct()
	{
		parent::__construct();
	}

	public function returnTable()
	{
		return $this->PracticeTest;
	}

	public function hasPracticeTest($id)
	{
		$q = $this->wpdb->get_var("SELECT post_id FROM ".$this->returnTable()." WHERE post_id=".$id);
		return !empty($q) ? true : false;
	}

	public function getPracticeTest($id)
	{
		return $this->wpdb->get_row("SELECT * FROM ".$this->returnTable()." WHERE post_id=".$id);
	}

	public function getPostByID($id,$post_id)
	{
		return $this->wpdb->get_var("SELECT ID FROM ".$this->wpdb->posts." WHERE post_author=".$id." AND ID=".$post_id);
	}

	public function getTime($id)
	{
		return $this->wpdb->get_var("SELECT time FROM ".$this->returnTable()." WHERE id=".$id);
	}

}